<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/


// Authentication Routes...
Route::get('login', 'Auth\LoginController@showLoginForm')->name('login');
Route::post('login', 'Auth\LoginController@login')->middleware('throttle:10,1');//限制1分钟登录10次
Route::get('logout', 'Auth\LoginController@logout')->name('logout');

Route::group(['middleware' => 'auth'], function () {
    Route::view('/', 'dashboard');
    Route::view('/index', 'dashboard');
    Route::match(['get', 'post'], '/dashboard', function(){
        return view('dashboard');
    });

    // Example Routes
    Route::view('/examples/plugin', 'examples.plugin');
    Route::view('/examples/blank', 'examples.blank');

    //通用方法
    Route::group(['namespace'=>'Common'], function(){
        //文件上传
        Route::post('common/file/upload', 'FileController@upload');
        Route::post('common/file/delete', 'FileController@delete');
    });

    //权限管理
    Route::group(['namespace'=>'Perm'], function(){
        //用户管理
        Route::post('perm/user/password', 'UserController@password');
        Route::post('perm/user/{id}/state', 'UserController@state');
        Route::get('perm/user/table', 'UserController@table');
        Route::resource('perm/user', 'UserController');

        //角色管理
        Route::get('perm/role/table', 'RoleController@table');
        Route::resource('perm/role', 'RoleController');

        //权限管理
        Route::get('perm/permission/table', 'PermissionController@table');
        Route::resource('perm/permission', 'PermissionController');
    });

    //资讯管理
    Route::group(['namespace'=>'Art'], function(){
        //资讯分类管理
        Route::get('art/category/table', 'CategoryController@table');
        Route::resource('art/category', 'CategoryController');

        //资讯文章管理
        Route::post('art/article/field/{id}/{field}', 'ArticleController@updateField');
        Route::post('art/article/state/{state}', 'ArticleController@updateState');
        Route::post('art/article/sort', 'ArticleController@sort');
        Route::get('art/article/table', 'ArticleController@table');
        Route::get('art/article/export/excel', 'ArticleController@exportExcel');
        Route::resource('art/article', 'ArticleController');
    });
});
